﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using PominaScale.Properties;
using System.IO.Ports;
using System.Drawing.Printing;

namespace PominaScale
{
    class Common
    {

        internal static UserModel UserLogin;

        private static SerialPort _port;
        internal static SerialPort Port
        {
            get {
                if (null == _port)
                    _port = new SerialPort();

                if (!_port.IsOpen)
                {
                    Configuration config = new Configuration();

                    _port.PortName = config.PortName;
                    _port.BaudRate = config.BaudRate;
                    _port.Parity = (System.IO.Ports.Parity)config.Parity;
                    _port.DataBits = config.DataBits;
                    _port.StopBits = (System.IO.Ports.StopBits)config.StopBits;
                }

                return _port; 
            }
        }

        // Folder in processing.

        internal static string MM_S2C
        {
            get { return Settings.Default.MM_S2C + Settings.Default.FileMM_S2C; }
        }
        internal static string SD_S2C
        {
            get { return Settings.Default.SD_S2C + Settings.Default.FileSD_S2C; }
        }
        internal static string MM_C2S
        {
            get { return Settings.Default.MM_C2S + Settings.Default.FileMM_C2S; }
        }
        internal static string SD_C2S
        {
            get { return Settings.Default.SD_C2S + Settings.Default.FileSD_C2S; }
        }
        internal static string Stored
        {
            get { return Settings.Default.Stored; }
        }
        internal static bool CheckPrinter(string printerName)
        {
            foreach (var item in PrinterSettings.InstalledPrinters)
            {
                if (item.Equals(printerName))
                    return true;
            }
            return false;
        }

    }
}
